﻿Imports MapleLib.PacketLib

Public Class PacketHandler
    Public Shared Sub HandleRecv(ByVal Packet As Byte(), ByVal C As MapleClient, ByVal m As Main)
        Dim Reader As New PacketReader(Packet)
        Dim Header As UShort = Reader.ReadShort()
        Select Case Header
            Case RecvHeaders.ClientDone
                Dim toSend As New PacketWriter
                toSend.WriteShort(SendHeaders.ClientDone)
                C.SendPacket(toSend)
            Case RecvHeaders.LoginPassword
                Using Handler As New LoginHandler(C, m, Reader)
                End Using
            Case RecvHeaders.WorldSelect
                Dim toSend As New PacketWriter
                toSend.WriteShort(SendHeaders.WorldSelectResponse)
                toSend.WriteShort(0)
                C.SendPacket(toSend)
            Case RecvHeaders.AuthDone
                C.SendPacket(MaplePacketCreator.LoggedIn(C))
                C.SendPacket(MaplePacketCreator.SendCharList(C))
            Case Else
                m.WriteLine(String.Format("Packet with header &H{0} not implented", Hex(Header)), 2)
        End Select
    End Sub
End Class
